# load data
dag <- read_csv(here("Data", "dag.csv")) %>% filter(cite_weight > 0)
node_attributes <- read_csv(here("data", "node_attributes.csv"))# all edges
edges <- lit$edgelist %>%
mutate(
detail = paste(edge, mechanism, cites, sep = "<br>") %>% str_remove_all("NA"),
type = edge,
title = paste0("<p>", detail, "</p>"),
#label = type,
color = ifelse(str_detect(type, "^increase"), "#81a275", "#617d9f"),
color = ifelse(str_detect(type, "^decrease"), "#b14552", color),
value = cite_weight) %>%
distinct()
core <- edges %>% filter(core, !is.na(cites))
cited <- edges %>% filter(cite_weight>0)
# node attributes
nodes <- lit$nodelist %>% mutate(label = node,
id = node,
# scale nodes by degree
icon.size = degree + 40,
title = paste0("<p>", type, ": ", label,"</p>") %>% str_remove("NA:"),
# levels in case we want Hierarchical Layout
level = ifelse(type == "goal", 1:2, 3:4),
# FontAwesome.com shapes for fun
shape = "icon",
icon.color = case_when(node %in% c(cited$to, cited$from) ~ "black",
!node %in% c(cited$to, cited$from) ~ "grey"),
icon.code = case_when(type == "condition" ~ "f205", # chess board
type == "goal" ~ "f24e", # scale "f05b", # crosshairs
type == "policy" ~ "f0e3", # gavel
type == "value" ~ "f004", # "f4be", # hand with heart
type == "effect" ~ "f080", # "f681", # data
type == "metric" ~ "f1de",# "f548", # ruler
TRUE ~ "f0c8"), #square
icon.face = "'FontAwesome'",
icon.weight = "bold")
# OLD CODE - REPLACE
# define function to plot
dag_plot <- function(dag){
node <- c(dag$from,
dag$to)
nodes <- tibble(id = node %>% str_remove(".* - "),
type = node %>% str_remove(" - .*")) %>%
filter(!is.na(id)) %>%
distinct() %>%
# removed nodes with multiple types
add_count(id) %>%
filter(n == 1)
edges <- dag %>% transmute(
from = from %>% str_remove(".* - "),
to = to %>% str_remove(".* - "),
detail = paste(edge, mechanism, cites, sep = "<br>") %>% str_remove_all("NA"),
type = edge
) %>%
filter(!is.na(from),!is.na(to)) %>%
distinct()
# calculate betweeness in order to scale nodes
graph <- igraph::graph.data.frame(edges, directed = T)
degree_value <- degree(graph, mode = "in")
nodes$icon.size <- degree_value[match(nodes$id, names(degree_value))] + 40
# add attributes
nodes <- nodes %>% mutate(label = id,
title = paste0("<p>", type, ": ", label,"</p>"),
# levels in case we want Hierarchical Layout
level = ifelse(type == "goal", 1:2, 3:4),
# FontAwesome.com shapes for fun
shape = "icon",
icon.color = case_when(type =="goal" ~ "black",
type !="goal" ~ "black"),
icon.code = case_when(type == "condition" ~ "f205", # chess board
type == "goal" ~ "f24e", # scale "f05b", # crosshairs
type == "policy" ~ "f0e3", # gavel
type == "value" ~ "f004", # "f4be", # hand with heart
type == "effect" ~ "f080", # "f681", # data
type == "metric" ~ "f1de",# "f548", # ruler
TRUE ~ "f0c8"), #square
icon.face = "'FontAwesome'",
icon.weight = "bold")
# format edges
edges <- edges %>% mutate(
title = paste0("<p>", detail, "</p>"),
#label = type,
color = ifelse(str_detect(type, "^increase"), "#81a275", "#617d9f"),
color = ifelse(str_detect(type, "^decrease"), "#b14552", color) )
# make directed graph
visNetwork(nodes=nodes, edges=edges, width = "100%") %>%
visEdges(width=5, color= edges$color, arrows = "to", arrowStrikethrough = F, smooth = T) %>%
visNodes(scaling=list(min=40, max=50)) %>%
visOptions(highlightNearest = list(enabled = T, degree = 1, hover = T)) %>%
visInteraction(hover=TRUE, zoomView = TRUE) %>%
#visHierarchicalLayout() %>%
visPhysics(solver = "forceAtlas2Based", forceAtlas2Based = list(gravitationalConstant = -50)) %>%
addFontAwesome(name = "font-awesome-visNetwork") %>%
visLayout(randomSeed = 12) # to have always the same network
# save datasets to call in Shiny
#save(nodes, file = here::here("dag", "nodes.RData"))
#save(edges, file = here::here("dag", "edges.RData"))
}# plot core nodes
dag_plot(dag %>% filter(core) )# plot core nodes
dag_plot(dag)NetLit R PackageHow do we convert these data into a network object in R? There are multiple packages to work with networks, but the most popular is igraph because it’s very flexible and easy to do. Other packages that you may want to explore are sna and networks.
Now, how do we create the igraph object? We can use the graph_from_data_frame function, which takes two arguments: d, the data frame with the edge list in the first two columns; and vertices, a data frame with node data with the node label in the first column. (Note that igraph calls the nodes vertices, but it’s exactly the same thing.)
The review package from the netLit package provides a wrapper for formatting data for igraph. It returns a list of three objects, an edgelist, a nodelist with basic network statistics (eg betweenness) calculated, and a graph object that is the input to more advanced igraph functions.
#devtools::install_github("judgelord/literature")
library(literature)
lit <- review(dag)
edges <- lit$edgelist
kablebox(edges)| from | to | edge_betweenness |
|---|---|---|
| computers | detect gerrymandering | 1.0 |
| computers | public participation | 1.0 |
| legislator information about district | floor votes align with district preferences | 1.0 |
| partisan advantage | proportionality | 12.0 |
| partisan advantage | number of competitive districts | 1.5 |
| maintaining communities | constitutional test | 1.0 |
| mean-median vote comparison | detect gerrymandering | 1.0 |
| mean-median vote comparison | constitutional test | 1.0 |
| partisan gerrymandering | unconstitutional government interest | 2.0 |
| partisan gerrymandering | instability | 2.0 |
| partisan gerrymandering | elite polarization | 2.0 |
| majority minority districts | number of minority representatives | 1.0 |
| majority minority districts | number of competitive districts | 1.5 |
| majority minority districts | partisan advantage | 8.5 |
| majority minority districts | voter turnout | 1.0 |
| redistricting commission | partisan gerrymandering | 5.0 |
| social network | vote outcome | 1.0 |
| partisan gerrymandering | concentration of likely donors in map-drawing party’s districts | 2.0 |
| change in constituency boundaries | legislator voting | 1.0 |
| change in constituency boundaries | legislative outcomes | 1.0 |
| competitiveness | voter turnout | 3.0 |
| demographic and ideological sorting | elite polarization | 1.0 |
| contiguity | partisan advantage | 10.0 |
| electorate composition change | incumbent vote share | 1.0 |
| electorate composition change | personal vote | 1.0 |
| House-Senate Delegation alignment | pork spending | 6.0 |
| incumbent’s constituents change | number of competitive districts | 2.0 |
| stability in voters’ fellow constituents | voter sense of place | 2.0 |
| voter information about their district | rolloff | 1.0 |
| voter information about their district | voter recall | 2.0 |
| voter information about their district | split ticket voting | 2.0 |
| electorate composition change | campaign resource allocation | 1.0 |
| geographic clustering | partisan advantage | 10.0 |
| communities preserved | stability in voters’ fellow constituents | 2.0 |
| communities preserved | voter information about their district | 3.0 |
| communities preserved | rolloff | 1.0 |
| number of competitive districts | elite polarization | 2.5 |
| partisan advantage | floor votes align with district preferences | 4.0 |
| partisan advantage | Alignment of floor vote breakdown with statewide majority of voters | 4.0 |
| partisan advantage | partisan advantage | 0.0 |
| partisan advantage | legislator voting | 4.0 |
| partisan advantage | elite polarization | 3.5 |
| partisan advantage | efficiency gap | 4.0 |
| partisan advantage | number of competitive districts | 1.5 |
| proportionality | House-Senate Delegation alignment | 10.0 |
| compactness | minority representation | 1.0 |
| compactness | compactness | 0.0 |
| efficiency gap | efficiency gap | 0.0 |
| equal population | equal population | 0.0 |
| redistricting commission | representation of majority opinion | 1.0 |
| redistricting commission | elite ideological moderation | 1.0 |
| redistricting commission | competitiveness | 2.0 |
| redistricting by courts | competitiveness | 2.0 |
| upcoming redistricting | legislative majority-seeking behavior | 1.0 |
| community | community | 0.0 |
nodes <- lit$nodelist
kablebox(nodes)| node | degree | betweenness |
|---|---|---|
| detect gerrymandering | 2 | 0.0 |
| public participation | 1 | 0.0 |
| floor votes align with district preferences | 2 | 0.0 |
| proportionality | 1 | 8.0 |
| number of competitive districts | 4 | 1.5 |
| constitutional test | 2 | 0.0 |
| unconstitutional government interest | 1 | 0.0 |
| instability | 1 | 0.0 |
| elite polarization | 4 | 0.0 |
| number of minority representatives | 1 | 0.0 |
| partisan advantage | 4 | 25.5 |
| voter turnout | 2 | 0.0 |
| partisan gerrymandering | 1 | 4.0 |
| vote outcome | 1 | 0.0 |
| concentration of likely donors in map-drawing party’s districts | 1 | 0.0 |
| legislator voting | 2 | 0.0 |
| legislative outcomes | 1 | 0.0 |
| incumbent vote share | 1 | 0.0 |
| personal vote | 1 | 0.0 |
| pork spending | 1 | 0.0 |
| voter sense of place | 1 | 0.0 |
| rolloff | 2 | 0.0 |
| voter recall | 1 | 0.0 |
| split ticket voting | 1 | 0.0 |
| campaign resource allocation | 1 | 0.0 |
| stability in voters’ fellow constituents | 1 | 1.0 |
| voter information about their district | 1 | 2.0 |
| Alignment of floor vote breakdown with statewide majority of voters | 1 | 0.0 |
| efficiency gap | 2 | 0.0 |
| House-Senate Delegation alignment | 1 | 5.0 |
| minority representation | 1 | 0.0 |
| compactness | 1 | 0.0 |
| equal population | 1 | 0.0 |
| representation of majority opinion | 1 | 0.0 |
| elite ideological moderation | 1 | 0.0 |
| competitiveness | 2 | 2.0 |
| legislative majority-seeking behavior | 1 | 0.0 |
| community | 1 | 0.0 |
| computers | 0 | 0.0 |
| legislator information about district | 0 | 0.0 |
| maintaining communities | 0 | 0.0 |
| mean-median vote comparison | 0 | 0.0 |
| majority minority districts | 0 | 0.0 |
| redistricting commission | 0 | 0.0 |
| social network | 0 | 0.0 |
| change in constituency boundaries | 0 | 0.0 |
| demographic and ideological sorting | 0 | 0.0 |
| contiguity | 0 | 0.0 |
| electorate composition change | 0 | 0.0 |
| incumbent’s constituents change | 0 | 0.0 |
| geographic clustering | 0 | 0.0 |
| communities preserved | 0 | 0.0 |
| redistricting by courts | 0 | 0.0 |
| upcoming redistricting | 0 | 0.0 |
# now with node and edge attributes
lit <- review(dag
,edge_attributes = c("mechanism", "cites", "cites_empirical", "cite_weight", "cite_weight_empirical")
#,node_attributes = node_attributes
)
edges <- lit$edgelist
kablebox(edges)| from | to | mechanism | cites | cites_empirical | cite_weight | edge_betweenness |
|---|---|---|---|---|---|---|
| computers | detect gerrymandering | Altman and McDonald (2010) argue that simulations cannot adequately detect gerrymanders. Wang proposes three tests to detect the effects and intents of gerrymanders. Altman and McDonald (2011) provide an open source program for redistricting analysis | Altman & McDonald 2010, Wang 2016, Altman & McDonald 2011 | Wang 2016 | 1 | 1.0 |
| computers | public participation | Altman & McDonald argue that computers can be used to allow the public to participate in the map-drawing process by soliciting information and education about redistricting. | Altman & McDonald 2010, Altman & McDonald 2011 | NA | 1 | 1.0 |
| legislator information about district | floor votes align with district preferences | NA | Butler, D and Nickerson, D 2011; Broockman and Skovron 2018; and Hertel-Fernandez et al. 2018 | NA | 3 | 1.0 |
| partisan advantage | proportionality | A partisan gerrymander aims to diverge from proportionality. | Caughey et al. 2017 | NA | 1 | 12.0 |
| partisan advantage | number of competitive districts | A partisan gerrymander aims to decrease the number of competitive district, but some research suggests that partisan gerrymanders have a neutral or positive effect on competition. | NA | NA | 5 | 1.5 |
| maintaining communities | constitutional test | Stephanopoulos argues that the Supreme Court ought to adopt a test of political gerrymandering based on the “territorial community.” In short, if a district map disrupts an organic geographic community, it is unconstitutional. | Stephanopoulos 2012 | NA | 1 | 1.0 |
| mean-median vote comparison | detect gerrymandering | McDonald & Best propose a new measure of detecting gerrymanders; compare a party’s median vote share in a district to its mean vote share. Wang proposes a similar measure of gerrymandering based on comparing mean and median vote shares. | McDonald & Best 2015, Wang 2016 | Wang 2016 | 1 | 1.0 |
| mean-median vote comparison | constitutional test | McDonald & Best argue that their measure of gerryamndering can be extended to identify which gerrymanders are unconstitutional | McDonald & Best 2015 | NA | 1 | 1.0 |
| partisan gerrymandering | unconstitutional government interest | Kang argues that it is unconstitutional for the government to take partisanship into account when determining district lines | Kang 2017 | NA | 1 | 2.0 |
| partisan gerrymandering | instability | Partisan mapmakers can create political instability, particularly for their opponent legislators, by breaking the link between representatives and constituents | Yoshinaka & Murhpy 2011 | Yoshinaka & Murhpy 2011 | 1 | 2.0 |
| partisan gerrymandering | elite polarization | Masket et al. find that partisan redistricting do not have much effect on legislative polarization, as it is swamped by other factors | Masket et al. 2012 | Masket et al. 2012 | 1 | 2.0 |
| majority minority districts | number of minority representatives | Where minorities are a majority, they are have a better chance of electing a representative; Atsusaka 2021 creates a logical model that allows minority candidate appearance to be a result of (1) the electoral performance of coethnic candidates in the most recent elections and (2) the racial composition of a district. | Atsusaka 2021 | Atsusaka 2021 | 1 | 1.0 |
| majority minority districts | number of competitive districts | NA | NA | NA | 2 | 1.5 |
| majority minority districts | partisan advantage | Cox and Holden argue that the optimal gerrymandering strategy is to cluster your strong partisan supporters into districts with a smaller number of strong partisan opponents. Thus, the Voting Rights Act’s majority-minority districts limit Republicans’ ability to effectively gerrymander. | Cox & Holden 2011 | NA | 1 | 8.5 |
| majority minority districts | voter turnout | African Americans are more likely to vote when reassigned to a majority black district. Fraga relies on a theoretical “empowerment framework,” in which members of minority groups are more likely to participate when their group has representation and influence in politics. | Fraga 2016 | Fraga 2016 | 1 | 1.0 |
| redistricting commission | partisan gerrymandering | Cain argues that independent citizen redistricting commissions are less likely to produce extremely partisan maps because they need to satisfy a supermajority by compromising on various redistricting criteria. | Cain 2011 | NA | 1 | 5.0 |
| social network | vote outcome | Stewart et al. introduce a concept called “information gerrymandering,” in which a small number of partisan extremists can sway the vote of the group towards their party. | Stewart et al. 2019 | NA | 1 | 1.0 |
| partisan gerrymandering | concentration of likely donors in map-drawing party’s districts | Parties care about other resources in addition to votes, such as donations. They can use redistricting to concentrate likely donors into their districts and remove them from opponents’ districts, thus increasing their odds of reelection. | Kirkland 2013 | Kirkland 2013 | 1 | 2.0 |
| change in constituency boundaries | legislator voting | Bertelli and Carson argue that partisan gerrymandering is a form of risk-sharing, in which individual members do not have to radically change their positions while maintaining their odds of reelection. In contrast, Hayes et al. say that legislators respond to the demographic changes of their constituency after redistricting. | Bertelli & Carson 2011, Hayes et al. 2010 | Bertelli & Carson 2011, Hayes et al. 2010 | 1 | 1.0 |
| change in constituency boundaries | legislative outcomes | Bertelli & Carson: Partisan gerrymandering helps the majority party achieve its policy goals by increasing the odds of electoral success without requiring much sacrifice by individual members. Gul & Pesendorfer: use formal theory to show that policy outcomes are biased towards the redistricting party | Bertelli & Carson 2011, Gul & Pesendorfer 2010 | Bertelli & Carson 2011 | 1 | 1.0 |
| competitiveness | voter turnout | Moskowitz & Schneer 2019: Residents of competitive districts systematically differ from those in non-competitive districts, leading cross-sectional studies to erroneously find a relationship between competitiveness and turnout. In addition, most voters aren’t aware of the competitiveness of their House race. Hunt 2018: examines data from Florida during 2012 election and finds that change in competitiveness after redistricting has a small effect on turnout | Moskowitz & Schneer 2019; Hunt 2018 | Moskowitz & Schneer 2019; Hunt 2018 | 2 | 3.0 |
| demographic and ideological sorting | elite polarization | Krasa & Polborn 2018: electoral competition model where gerrymandering (“intensification of the median ideological preferences in some districts”) can result in increased partisan polarization | Krasa & Polborn 2018 | Krasa & Polborn 2018 | 1 | 1.0 |
| contiguity | partisan advantage | Democrats’ concentration in cities leads to a Republican bias, due to the geographic, majoritarian nature of U.S. elections. | Chen & Rodden 2013 | Chen & Rodden 2013 | 1 | 10.0 |
| electorate composition change | incumbent vote share | Redistricting destroys the connection between a representative and their constituents; the new constituents have no such bond, so incumbency advantage is lower. | Hood & McKee 2013 | Hood & McKee 2013 | 1 | 1.0 |
| electorate composition change | personal vote | When a legislator’s district changes, the personal connection with some of their constituents is lost. Thus, legislators are less able to convert supporters of the opposite party, as they have no connections with their new constituents. | Carsey et al. 2017, Bertelli & Carson 2011 | Carsey et al. 2017 | 1 | 1.0 |
| House-Senate Delegation alignment | pork spending | NA | Chen 2010 | NA | 1 | 6.0 |
| incumbent’s constituents change | number of competitive districts | NA | NA | NA | 1 | 2.0 |
| stability in voters’ fellow constituents | voter sense of place | NA | Hayes & McKee 2011 | Hayes & McKee 2011 | 1 | 2.0 |
| voter information about their district | rolloff | NA | Winburn & Wagner 2010 | NA | 1 | 1.0 |
| voter information about their district | voter recall | NA | Winburn & Wagner 2010 | NA | 1 | 2.0 |
| voter information about their district | split ticket voting | NA | Winburn & Wagner 2010 | NA | 1 | 2.0 |
| electorate composition change | campaign resource allocation | Candidates have their own campaign style, so their resource allocation decisions do not change even when the electoral circumstances change. | Limbocker & You 2020 | Limbocker & You 2020 | 1 | 1.0 |
| geographic clustering | partisan advantage | Democrats are inefficiently geographically distributed; they run up the score in large cities which leads to a discrepency between total vote share and seat share. | Chen & Rodden 2013 | Chen & Rodden 2013 | 1 | 10.0 |
| communities preserved | stability in voters’ fellow constituents | NA | Winburn & Wagner 2010 | NA | 1 | 2.0 |
| communities preserved | voter information about their district | NA | Winburn & Wagner 2010 | NA | 1 | 3.0 |
| communities preserved | rolloff | NA | Hayes & McKee 2011; Winburn & Wagner 2010 | Hayes & McKee 2011 | 2 | 1.0 |
| number of competitive districts | elite polarization | Safe partisan seats tend to increase partisan polarization. | Grainger 2010 | Grainger 2010 | 1 | 2.5 |
| partisan advantage | floor votes align with district preferences | TODO | Caughey et al. 2017 | NA | 1 | 4.0 |
| partisan advantage | Alignment of floor vote breakdown with statewide majority of voters | TODO | Caughey et al. 2017 | NA | 1 | 4.0 |
| partisan advantage | partisan advantage | Measures of partisan symmetry/bias/advantage | Katz, King & Rosenblatt 2020 | NA | 1 | 0.0 |
| partisan advantage | legislator voting | Legislators do not change their ideological positions after redistricting (though The Electoral Connection suggests they should) | Lo 2013 | Lo 2013 | 1 | 4.0 |
| partisan advantage | elite polarization | Because vulnerable legislators do not moderate their positions, Lo assumes that safe legislators do not become more extreme | Lo 2013 | NA | 1 | 3.5 |
| partisan advantage | efficiency gap | Gerrymandering does not affect the electoral results in most states, and in the states where it does have an effect, the effect is small. Republicans are expected to net only one additional seat in Congress due to gerrymandering. | Chen & Cottrell 2016 | Chen & Cottrell 2016 | 1 | 4.0 |
| partisan advantage | number of competitive districts | Large changes in the national partisan tide causes garrymanders to backfire on the map-drawing party (an effect known as the “dummymander”), as their members face unexpectedly competitive elections. | Goedert 2017 | Goedert 2017, Yoshinaka & Murhpy 2011 | 1 | 1.5 |
| proportionality | House-Senate Delegation alignment | NA | Chen 2010 | NA | 1 | 10.0 |
| compactness | minority representation | Webster 2013: citing earlier research, Webster posits that compactness hinders a map drawer’s ability to create districts for historically underrepresented groups. | Webster 2013 | NA | 1 | 1.0 |
| compactness | compactness | Barnes & Solomon 2020: measuring compactness can have associated flexibility that can be abused (geography, topography, cartographic projections, and resolution); Gatesman & Unwin 2021: lattice models for accounting gerrymandered, equal-pop, connected districts; Magleby & Mosesson 2018: graph partition algorithm for drawing districts based on compactness and equal population metrics.De Assis et al. 2014: Greedy randomized adaptive search procedure can balance multiple criteria, including compactness. Altman & McDonald 2011: produce an open source package that allows users to adjust weights of redistricting criteria, including redistricting. Liu et al.; propose a method of parallel evolutionary computation to solve the optimization problem of redistricting. Chen & Rodden; simulation-based method also takes compactness into account to draw district maps and identify gerrymanders. Tam Cho & Liu; use compactness in their redistricting algorithm. Saxon 2020: software for applying compactness/contiguity/equipopulation objectives to evaluate maps – specific focus on different definitions of compactness. | Barnes & Solomon 2020; Gatesman & Unwin 2021; Magleby & Mosesson 2018; De Assis et al. 2014; Altman & McDonald 2011; Lie et al. 2016, Chen & Rodden 2015, Tam Cho & Liu 2016, Saxon 2020 | Barnes & Solomon 2020; Magleby & Mosesson 2018; De Assis et al. 2014; Chen & Rodden 2015, Tam Cho & Liu 2016, Saxon 2020 | 6 | 0.0 |
| efficiency gap | efficiency gap | Stephanopoulos and McGhee propose a measure of partisan symmetry to be adopted by the courts, in order to limit partisan influence over redistricting; McGhee distinguishes efficiency from related concepts of symmetry and responsiveness | Stephanopoulos & McGhee 2015, McGhee 2014 | McGhee 2014 | 1 | 0.0 |
| equal population | equal population | Gatesman & Unwin 2021: lattice models for accounting gerrymandered, equal-pop, connected districts; Magleby & Mosesson 2018: graph partition algorithm for drawing districts based on compactness and equal population metrics. Altman & McDonald 2011: produce an open source package that allows users to adjust weights of redistricting criteria, including equality of population | Gatesman & Unwin 2021; Magleby & Mosesson 2018 | Magleby & Mosesson 2018 | 2 | 0.0 |
| redistricting commission | representation of majority opinion | Matsusaka does not discuss a mechanism for this relationship, but finds that other electoral rules, such as campaign finance regulations and ballot access rules, are also not associated with greater congruence between public opinion and legislative behavior. | Matsusaka 2010 | Matsusaka 2010 | 1 | 1.0 |
| redistricting commission | elite ideological moderation | McGhee and Shor focus on the effect of the Top Two primary on elite moderation, but argue that the introduction of independent redistricting commissions may also lead to greater moderation by creating more competitive districts. | McGhee & Shor 2017 | McGhee & Shor 2017 | 1 | 1.0 |
| redistricting commission | competitiveness | Carson et al.: increased ideological polarization and the availability of redistricting computer software encourages elites to draw non-competitive districts in order to increase their odds of reelection. Masket et al.: partisan redistricting does not effect competition much and is swamped by other factors | Carson et al. 2014, Grainger 2010, Masket et al. 2012 | Carson et al. 2014, Grainger 2010, Masket et al. 2012 | 1 | 2.0 |
| redistricting by courts | competitiveness | NA | Carson et al. 2014 | Carson et al. 2014 | 1 | 2.0 |
| upcoming redistricting | legislative majority-seeking behavior | Parties have a greater incentive to become the majority party in the state legislature if redistricting is imminent and controlled by the legislature, as they can then determine the new district boundaries | Makse 2014 | Makse 2014 | 1 | 1.0 |
| community | community | Deford, Eubank & Rodden 2020: new measure “partisan dislocation” which proxies for cracking/packing | Deford, Eubank & Rodden 2020 | NA | 1 | 0.0 |
nodes <- lit$nodelist
kablebox(nodes)| node | degree | betweenness |
|---|---|---|
| detect gerrymandering | 2 | 0.0 |
| public participation | 1 | 0.0 |
| floor votes align with district preferences | 2 | 0.0 |
| proportionality | 1 | 8.0 |
| number of competitive districts | 4 | 1.5 |
| constitutional test | 2 | 0.0 |
| unconstitutional government interest | 1 | 0.0 |
| instability | 1 | 0.0 |
| elite polarization | 4 | 0.0 |
| number of minority representatives | 1 | 0.0 |
| partisan advantage | 4 | 25.5 |
| voter turnout | 2 | 0.0 |
| partisan gerrymandering | 1 | 4.0 |
| vote outcome | 1 | 0.0 |
| concentration of likely donors in map-drawing party’s districts | 1 | 0.0 |
| legislator voting | 2 | 0.0 |
| legislative outcomes | 1 | 0.0 |
| incumbent vote share | 1 | 0.0 |
| personal vote | 1 | 0.0 |
| pork spending | 1 | 0.0 |
| voter sense of place | 1 | 0.0 |
| rolloff | 2 | 0.0 |
| voter recall | 1 | 0.0 |
| split ticket voting | 1 | 0.0 |
| campaign resource allocation | 1 | 0.0 |
| stability in voters’ fellow constituents | 1 | 1.0 |
| voter information about their district | 1 | 2.0 |
| Alignment of floor vote breakdown with statewide majority of voters | 1 | 0.0 |
| efficiency gap | 2 | 0.0 |
| House-Senate Delegation alignment | 1 | 5.0 |
| minority representation | 1 | 0.0 |
| compactness | 1 | 0.0 |
| equal population | 1 | 0.0 |
| representation of majority opinion | 1 | 0.0 |
| elite ideological moderation | 1 | 0.0 |
| competitiveness | 2 | 2.0 |
| legislative majority-seeking behavior | 1 | 0.0 |
| community | 1 | 0.0 |
| computers | 0 | 0.0 |
| legislator information about district | 0 | 0.0 |
| maintaining communities | 0 | 0.0 |
| mean-median vote comparison | 0 | 0.0 |
| majority minority districts | 0 | 0.0 |
| redistricting commission | 0 | 0.0 |
| social network | 0 | 0.0 |
| change in constituency boundaries | 0 | 0.0 |
| demographic and ideological sorting | 0 | 0.0 |
| contiguity | 0 | 0.0 |
| electorate composition change | 0 | 0.0 |
| incumbent’s constituents change | 0 | 0.0 |
| geographic clustering | 0 | 0.0 |
| communities preserved | 0 | 0.0 |
| redistricting by courts | 0 | 0.0 |
| upcoming redistricting | 0 | 0.0 |
# define node name
nodes$name <- nodes$node
g <- lit$graph
g## IGRAPH 3476abf DN-- 54 55 --
## + attr: name (v/c), degree (v/n), betweenness (v/n), mechanism (e/c),
## | cites (e/c), cites_empirical (e/c), cite_weight (e/n),
## | edge_betweenness (e/n)
## + edges from 3476abf (vertex names):
## [1] computers ->detect gerrymandering
## [2] computers ->public participation
## [3] legislator information about district->floor votes align with district preferences
## [4] partisan advantage ->proportionality
## [5] partisan advantage ->number of competitive districts
## + ... omitted several edges
What does it mean?
D means directedN means named graphW means weighted graphname (v/c) means name is a node attribute and it’s a charactercite_weight (e/n) means cite_weight is an edge attribute and it’s numericPractice accessing the following elements of the network: nodes, names of the nodes, attributes of the nodes, edges, weights for each edge, all attributes of the edges, the adjacency matrix, and just the first row of the adjacency matrix.
#V(g) # nodes
# V(g)$name %>% head() # names of each node
vertex_attr(g) %>% as_tibble() %>% kablebox()# all attributes of the nodes| name | degree | betweenness |
|---|---|---|
| detect gerrymandering | 2 | 0.0 |
| public participation | 1 | 0.0 |
| floor votes align with district preferences | 2 | 0.0 |
| proportionality | 1 | 8.0 |
| number of competitive districts | 4 | 1.5 |
| constitutional test | 2 | 0.0 |
| unconstitutional government interest | 1 | 0.0 |
| instability | 1 | 0.0 |
| elite polarization | 4 | 0.0 |
| number of minority representatives | 1 | 0.0 |
| partisan advantage | 4 | 25.5 |
| voter turnout | 2 | 0.0 |
| partisan gerrymandering | 1 | 4.0 |
| vote outcome | 1 | 0.0 |
| concentration of likely donors in map-drawing party’s districts | 1 | 0.0 |
| legislator voting | 2 | 0.0 |
| legislative outcomes | 1 | 0.0 |
| incumbent vote share | 1 | 0.0 |
| personal vote | 1 | 0.0 |
| pork spending | 1 | 0.0 |
| voter sense of place | 1 | 0.0 |
| rolloff | 2 | 0.0 |
| voter recall | 1 | 0.0 |
| split ticket voting | 1 | 0.0 |
| campaign resource allocation | 1 | 0.0 |
| stability in voters’ fellow constituents | 1 | 1.0 |
| voter information about their district | 1 | 2.0 |
| Alignment of floor vote breakdown with statewide majority of voters | 1 | 0.0 |
| efficiency gap | 2 | 0.0 |
| House-Senate Delegation alignment | 1 | 5.0 |
| minority representation | 1 | 0.0 |
| compactness | 1 | 0.0 |
| equal population | 1 | 0.0 |
| representation of majority opinion | 1 | 0.0 |
| elite ideological moderation | 1 | 0.0 |
| competitiveness | 2 | 2.0 |
| legislative majority-seeking behavior | 1 | 0.0 |
| community | 1 | 0.0 |
| computers | 0 | 0.0 |
| legislator information about district | 0 | 0.0 |
| maintaining communities | 0 | 0.0 |
| mean-median vote comparison | 0 | 0.0 |
| majority minority districts | 0 | 0.0 |
| redistricting commission | 0 | 0.0 |
| social network | 0 | 0.0 |
| change in constituency boundaries | 0 | 0.0 |
| demographic and ideological sorting | 0 | 0.0 |
| contiguity | 0 | 0.0 |
| electorate composition change | 0 | 0.0 |
| incumbent’s constituents change | 0 | 0.0 |
| geographic clustering | 0 | 0.0 |
| communities preserved | 0 | 0.0 |
| redistricting by courts | 0 | 0.0 |
| upcoming redistricting | 0 | 0.0 |
E(g) %>% head()# edges## + 6/55 edges from 3476abf (vertex names):
## [1] computers ->detect gerrymandering
## [2] computers ->public participation
## [3] legislator information about district->floor votes align with district preferences
## [4] partisan advantage ->proportionality
## [5] partisan advantage ->number of competitive districts
## [6] maintaining communities ->constitutional test
E(g)$cite_weight %>% head()# weights for each edge## [1] 1 1 3 1 5 1
edge_attr(g) %>% as_tibble() %>% kablebox()# all attributes of the edges| mechanism | cites | cites_empirical | cite_weight | edge_betweenness |
|---|---|---|---|---|
| Altman and McDonald (2010) argue that simulations cannot adequately detect gerrymanders. Wang proposes three tests to detect the effects and intents of gerrymanders. Altman and McDonald (2011) provide an open source program for redistricting analysis | Altman & McDonald 2010, Wang 2016, Altman & McDonald 2011 | Wang 2016 | 1 | 1.0 |
| Altman & McDonald argue that computers can be used to allow the public to participate in the map-drawing process by soliciting information and education about redistricting. | Altman & McDonald 2010, Altman & McDonald 2011 | NA | 1 | 1.0 |
| NA | Butler, D and Nickerson, D 2011; Broockman and Skovron 2018; and Hertel-Fernandez et al. 2018 | NA | 3 | 1.0 |
| A partisan gerrymander aims to diverge from proportionality. | Caughey et al. 2017 | NA | 1 | 12.0 |
| A partisan gerrymander aims to decrease the number of competitive district, but some research suggests that partisan gerrymanders have a neutral or positive effect on competition. | NA | NA | 5 | 1.5 |
| Stephanopoulos argues that the Supreme Court ought to adopt a test of political gerrymandering based on the “territorial community.” In short, if a district map disrupts an organic geographic community, it is unconstitutional. | Stephanopoulos 2012 | NA | 1 | 1.0 |
| McDonald & Best propose a new measure of detecting gerrymanders; compare a party’s median vote share in a district to its mean vote share. Wang proposes a similar measure of gerrymandering based on comparing mean and median vote shares. | McDonald & Best 2015, Wang 2016 | Wang 2016 | 1 | 1.0 |
| McDonald & Best argue that their measure of gerryamndering can be extended to identify which gerrymanders are unconstitutional | McDonald & Best 2015 | NA | 1 | 1.0 |
| Kang argues that it is unconstitutional for the government to take partisanship into account when determining district lines | Kang 2017 | NA | 1 | 2.0 |
| Partisan mapmakers can create political instability, particularly for their opponent legislators, by breaking the link between representatives and constituents | Yoshinaka & Murhpy 2011 | Yoshinaka & Murhpy 2011 | 1 | 2.0 |
| Masket et al. find that partisan redistricting do not have much effect on legislative polarization, as it is swamped by other factors | Masket et al. 2012 | Masket et al. 2012 | 1 | 2.0 |
| Where minorities are a majority, they are have a better chance of electing a representative; Atsusaka 2021 creates a logical model that allows minority candidate appearance to be a result of (1) the electoral performance of coethnic candidates in the most recent elections and (2) the racial composition of a district. | Atsusaka 2021 | Atsusaka 2021 | 1 | 1.0 |
| NA | NA | NA | 2 | 1.5 |
| Cox and Holden argue that the optimal gerrymandering strategy is to cluster your strong partisan supporters into districts with a smaller number of strong partisan opponents. Thus, the Voting Rights Act’s majority-minority districts limit Republicans’ ability to effectively gerrymander. | Cox & Holden 2011 | NA | 1 | 8.5 |
| African Americans are more likely to vote when reassigned to a majority black district. Fraga relies on a theoretical “empowerment framework,” in which members of minority groups are more likely to participate when their group has representation and influence in politics. | Fraga 2016 | Fraga 2016 | 1 | 1.0 |
| Cain argues that independent citizen redistricting commissions are less likely to produce extremely partisan maps because they need to satisfy a supermajority by compromising on various redistricting criteria. | Cain 2011 | NA | 1 | 5.0 |
| Stewart et al. introduce a concept called “information gerrymandering,” in which a small number of partisan extremists can sway the vote of the group towards their party. | Stewart et al. 2019 | NA | 1 | 1.0 |
| Parties care about other resources in addition to votes, such as donations. They can use redistricting to concentrate likely donors into their districts and remove them from opponents’ districts, thus increasing their odds of reelection. | Kirkland 2013 | Kirkland 2013 | 1 | 2.0 |
| Bertelli and Carson argue that partisan gerrymandering is a form of risk-sharing, in which individual members do not have to radically change their positions while maintaining their odds of reelection. In contrast, Hayes et al. say that legislators respond to the demographic changes of their constituency after redistricting. | Bertelli & Carson 2011, Hayes et al. 2010 | Bertelli & Carson 2011, Hayes et al. 2010 | 1 | 1.0 |
| Bertelli & Carson: Partisan gerrymandering helps the majority party achieve its policy goals by increasing the odds of electoral success without requiring much sacrifice by individual members. Gul & Pesendorfer: use formal theory to show that policy outcomes are biased towards the redistricting party | Bertelli & Carson 2011, Gul & Pesendorfer 2010 | Bertelli & Carson 2011 | 1 | 1.0 |
| Moskowitz & Schneer 2019: Residents of competitive districts systematically differ from those in non-competitive districts, leading cross-sectional studies to erroneously find a relationship between competitiveness and turnout. In addition, most voters aren’t aware of the competitiveness of their House race. Hunt 2018: examines data from Florida during 2012 election and finds that change in competitiveness after redistricting has a small effect on turnout | Moskowitz & Schneer 2019; Hunt 2018 | Moskowitz & Schneer 2019; Hunt 2018 | 2 | 3.0 |
| Krasa & Polborn 2018: electoral competition model where gerrymandering (“intensification of the median ideological preferences in some districts”) can result in increased partisan polarization | Krasa & Polborn 2018 | Krasa & Polborn 2018 | 1 | 1.0 |
| Democrats’ concentration in cities leads to a Republican bias, due to the geographic, majoritarian nature of U.S. elections. | Chen & Rodden 2013 | Chen & Rodden 2013 | 1 | 10.0 |
| Redistricting destroys the connection between a representative and their constituents; the new constituents have no such bond, so incumbency advantage is lower. | Hood & McKee 2013 | Hood & McKee 2013 | 1 | 1.0 |
| When a legislator’s district changes, the personal connection with some of their constituents is lost. Thus, legislators are less able to convert supporters of the opposite party, as they have no connections with their new constituents. | Carsey et al. 2017, Bertelli & Carson 2011 | Carsey et al. 2017 | 1 | 1.0 |
| NA | Chen 2010 | NA | 1 | 6.0 |
| NA | NA | NA | 1 | 2.0 |
| NA | Hayes & McKee 2011 | Hayes & McKee 2011 | 1 | 2.0 |
| NA | Winburn & Wagner 2010 | NA | 1 | 1.0 |
| NA | Winburn & Wagner 2010 | NA | 1 | 2.0 |
| NA | Winburn & Wagner 2010 | NA | 1 | 2.0 |
| Candidates have their own campaign style, so their resource allocation decisions do not change even when the electoral circumstances change. | Limbocker & You 2020 | Limbocker & You 2020 | 1 | 1.0 |
| Democrats are inefficiently geographically distributed; they run up the score in large cities which leads to a discrepency between total vote share and seat share. | Chen & Rodden 2013 | Chen & Rodden 2013 | 1 | 10.0 |
| NA | Winburn & Wagner 2010 | NA | 1 | 2.0 |
| NA | Winburn & Wagner 2010 | NA | 1 | 3.0 |
| NA | Hayes & McKee 2011; Winburn & Wagner 2010 | Hayes & McKee 2011 | 2 | 1.0 |
| Safe partisan seats tend to increase partisan polarization. | Grainger 2010 | Grainger 2010 | 1 | 2.5 |
| TODO | Caughey et al. 2017 | NA | 1 | 4.0 |
| TODO | Caughey et al. 2017 | NA | 1 | 4.0 |
| Measures of partisan symmetry/bias/advantage | Katz, King & Rosenblatt 2020 | NA | 1 | 0.0 |
| Legislators do not change their ideological positions after redistricting (though The Electoral Connection suggests they should) | Lo 2013 | Lo 2013 | 1 | 4.0 |
| Because vulnerable legislators do not moderate their positions, Lo assumes that safe legislators do not become more extreme | Lo 2013 | NA | 1 | 3.5 |
| Gerrymandering does not affect the electoral results in most states, and in the states where it does have an effect, the effect is small. Republicans are expected to net only one additional seat in Congress due to gerrymandering. | Chen & Cottrell 2016 | Chen & Cottrell 2016 | 1 | 4.0 |
| Large changes in the national partisan tide causes garrymanders to backfire on the map-drawing party (an effect known as the “dummymander”), as their members face unexpectedly competitive elections. | Goedert 2017 | Goedert 2017, Yoshinaka & Murhpy 2011 | 1 | 1.5 |
| NA | Chen 2010 | NA | 1 | 10.0 |
| Webster 2013: citing earlier research, Webster posits that compactness hinders a map drawer’s ability to create districts for historically underrepresented groups. | Webster 2013 | NA | 1 | 1.0 |
| Barnes & Solomon 2020: measuring compactness can have associated flexibility that can be abused (geography, topography, cartographic projections, and resolution); Gatesman & Unwin 2021: lattice models for accounting gerrymandered, equal-pop, connected districts; Magleby & Mosesson 2018: graph partition algorithm for drawing districts based on compactness and equal population metrics.De Assis et al. 2014: Greedy randomized adaptive search procedure can balance multiple criteria, including compactness. Altman & McDonald 2011: produce an open source package that allows users to adjust weights of redistricting criteria, including redistricting. Liu et al.; propose a method of parallel evolutionary computation to solve the optimization problem of redistricting. Chen & Rodden; simulation-based method also takes compactness into account to draw district maps and identify gerrymanders. Tam Cho & Liu; use compactness in their redistricting algorithm. Saxon 2020: software for applying compactness/contiguity/equipopulation objectives to evaluate maps – specific focus on different definitions of compactness. | Barnes & Solomon 2020; Gatesman & Unwin 2021; Magleby & Mosesson 2018; De Assis et al. 2014; Altman & McDonald 2011; Lie et al. 2016, Chen & Rodden 2015, Tam Cho & Liu 2016, Saxon 2020 | Barnes & Solomon 2020; Magleby & Mosesson 2018; De Assis et al. 2014; Chen & Rodden 2015, Tam Cho & Liu 2016, Saxon 2020 | 6 | 0.0 |
| Stephanopoulos and McGhee propose a measure of partisan symmetry to be adopted by the courts, in order to limit partisan influence over redistricting; McGhee distinguishes efficiency from related concepts of symmetry and responsiveness | Stephanopoulos & McGhee 2015, McGhee 2014 | McGhee 2014 | 1 | 0.0 |
| Gatesman & Unwin 2021: lattice models for accounting gerrymandered, equal-pop, connected districts; Magleby & Mosesson 2018: graph partition algorithm for drawing districts based on compactness and equal population metrics. Altman & McDonald 2011: produce an open source package that allows users to adjust weights of redistricting criteria, including equality of population | Gatesman & Unwin 2021; Magleby & Mosesson 2018 | Magleby & Mosesson 2018 | 2 | 0.0 |
| Matsusaka does not discuss a mechanism for this relationship, but finds that other electoral rules, such as campaign finance regulations and ballot access rules, are also not associated with greater congruence between public opinion and legislative behavior. | Matsusaka 2010 | Matsusaka 2010 | 1 | 1.0 |
| McGhee and Shor focus on the effect of the Top Two primary on elite moderation, but argue that the introduction of independent redistricting commissions may also lead to greater moderation by creating more competitive districts. | McGhee & Shor 2017 | McGhee & Shor 2017 | 1 | 1.0 |
| Carson et al.: increased ideological polarization and the availability of redistricting computer software encourages elites to draw non-competitive districts in order to increase their odds of reelection. Masket et al.: partisan redistricting does not effect competition much and is swamped by other factors | Carson et al. 2014, Grainger 2010, Masket et al. 2012 | Carson et al. 2014, Grainger 2010, Masket et al. 2012 | 1 | 2.0 |
| NA | Carson et al. 2014 | Carson et al. 2014 | 1 | 2.0 |
| Parties have a greater incentive to become the majority party in the state legislature if redistricting is imminent and controlled by the legislature, as they can then determine the new district boundaries | Makse 2014 | Makse 2014 | 1 | 1.0 |
| Deford, Eubank & Rodden 2020: new measure “partisan dislocation” which proxies for cracking/packing | Deford, Eubank & Rodden 2020 | NA | 1 | 0.0 |
# g[] %>% head # adjacency matrix
g[1,] %>% head # first row of adjacency matrix## detect gerrymandering
## 0
## public participation
## 0
## floor votes align with district preferences
## 0
## proportionality
## 0
## number of competitive districts
## 0
## constitutional test
## 0
How can we visualize this network? The plot() function works out of the box, but the default options are often not ideal:
par(mar=c(0,0,0,0))
plot(g)Improve this figure. To see all the available plotting options, you can check ?igraph.plotting. Set the vertex color, label colors, the size of the labels, curvature to the edge and edge color to ones different from the default settings and in a way that is visually appealing to you.
par(mar=c(0,0,0,0))
pdf(file="net.pdf")
plot(g,
vertex.color = "grey", # change color of nodes
vertex.label.color = "black", # change color of labels
vertex.label.cex = .25, # change size of labels to 25% of original size
edge.curved=.25, # add a 25% curve to the edges
arrow.size = .2,
edge.color="grey20") # change edge color to grey
dev.off()## quartz_off_screen
## 2
ggnetwork# install.packages("ggnetwork")
library(ggnetwork)
n <- ggnetwork(g)
library(magrittr)
n$name %<>% str_replace(" ", "\n")
n$name %<>% str_replace(" ([A-z]*)$", "\n\\1")
library(magrittr)
n$cite_weight %<>% replace_na(0)
n %<>% mutate(partisan = str_detect(name, "partisan"),
empirical = ifelse(!is.na(cites_empirical),
"Empirical work",
"No empirical work"))
n2 <- n %>% filter(partisan) %>% mutate(partisan = FALSE)
n %<>% full_join(n2) %>% mutate(partisan = ifelse(partisan, "Mentions partisanship", "Other nodes"))
set.seed(12)
n$cite_weight %<>% as_factor()
p <- ggplot(n) +
aes(x = x, y = y, xend = xend, yend = yend,
label = name %>% str_to_title()) +
geom_nodes(size = 10, alpha = .1) +
geom_edges(aes(color = cite_weight, linetype = empirical ),
curvature = 0.1,
alpha = .8,
#box.padding = unit(1, "lines"),
arrow = arrow(length = unit(6, "pt"), type = "closed")) +
geom_nodetext_repel(size = 2.3) +
theme_blank() +
labs(color = "Number of\nPublications",
linetype = "") +
scale_color_viridis_d(option = "plasma", begin = 0, end = .9, direction = -1)
pseedplot <- function(seed){
set.seed(seed)
p
}
seq <- seq(from = 1, to = 200, by= 50)
#map(seq, seedplot)
p <- p + geom_edgetext(aes(label = cites_empirical %>% str_remove(",.*"),
color = cite_weight),
size = 2,
alpha = .2)
pp + facet_wrap("partisan")Now modify some of these plotting attributes so that they are function of network properties. For example, a common adjustment is to change the size of the nodes and node labels so that they match their importance.
Here, strength will correspond to the number of scenes they appear in. Let the size of the node be determined by the strength, and only show the labels of character that appear in 10 or more scenes. Finally change the colors of the node based on what side they’re in (dark side or light side) and add an informative legend.
V(g)$size <- strength(g)
par(mar=c(0,0,0,0)); plot(g)# taking the log to improve it
V(g)$size <- log(strength(g)) * 4 + 3
par(mar=c(0,0,0,0)); plot(g)V(g)$label <- ifelse( strength(g)>=10, V(g)$name, NA )
par(mar=c(0,0,0,0)); plot(g)# what does `ifelse` do?
nodes$name=="minority rights"## [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [13] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [25] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [37] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [49] FALSE FALSE FALSE FALSE FALSE FALSE
ifelse(nodes$name=="minority rights", "yes", "no")## [1] "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no"
## [16] "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no"
## [31] "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no"
## [46] "no" "no" "no" "no" "no" "no" "no" "no" "no"
ifelse(grepl("rights", nodes$name), "yes", "no")## [1] "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no"
## [16] "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no"
## [31] "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no"
## [46] "no" "no" "no" "no" "no" "no" "no" "no" "no"
#change the colors of each node based on what side they're in (dark side or light side).
# create vectors with characters in each side
dark_side <- c("minority rights")
light_side <- c("")
# node we'll create a new color variable as a node property
V(g)$color <- NA
V(g)$color[V(g)$type == "goal"] <- "red"
V(g)$color[V(g)$type == "policy"] <- "gold"
V(g)$color[V(g)$type == "effect"] <- "blue"
V(g)$color[V(g)$type == "value"] <- "white"
V(g)$color[V(g)$type == "condition"] <- "green"
V(g)$color[V(g)$type == "metric"] <- "purple"
V(g)$color[is.na(V(g)$type)] <- "grey20"
vertex_attr(g) %>% as_tibble()%>% kablebox()| name | degree | betweenness | size | label | color |
|---|---|---|---|---|---|
| detect gerrymandering | 2 | 0.0 | 5.772589 | NA | NA |
| public participation | 1 | 0.0 | 3.000000 | NA | NA |
| floor votes align with district preferences | 2 | 0.0 | 5.772589 | NA | NA |
| proportionality | 1 | 8.0 | 5.772589 | NA | NA |
| number of competitive districts | 4 | 1.5 | 9.437752 | NA | NA |
| constitutional test | 2 | 0.0 | 5.772589 | NA | NA |
| unconstitutional government interest | 1 | 0.0 | 3.000000 | NA | NA |
| instability | 1 | 0.0 | 3.000000 | NA | NA |
| elite polarization | 4 | 0.0 | 8.545177 | NA | NA |
| number of minority representatives | 1 | 0.0 | 3.000000 | NA | NA |
| partisan advantage | 4 | 25.5 | 13.259797 | partisan advantage | NA |
| voter turnout | 2 | 0.0 | 5.772589 | NA | NA |
| partisan gerrymandering | 1 | 4.0 | 9.437752 | NA | NA |
| vote outcome | 1 | 0.0 | 3.000000 | NA | NA |
| concentration of likely donors in map-drawing party’s districts | 1 | 0.0 | 3.000000 | NA | NA |
| legislator voting | 2 | 0.0 | 5.772589 | NA | NA |
| legislative outcomes | 1 | 0.0 | 3.000000 | NA | NA |
| incumbent vote share | 1 | 0.0 | 3.000000 | NA | NA |
| personal vote | 1 | 0.0 | 3.000000 | NA | NA |
| pork spending | 1 | 0.0 | 3.000000 | NA | NA |
| voter sense of place | 1 | 0.0 | 3.000000 | NA | NA |
| rolloff | 2 | 0.0 | 5.772589 | NA | NA |
| voter recall | 1 | 0.0 | 3.000000 | NA | NA |
| split ticket voting | 1 | 0.0 | 3.000000 | NA | NA |
| campaign resource allocation | 1 | 0.0 | 3.000000 | NA | NA |
| stability in voters’ fellow constituents | 1 | 1.0 | 5.772589 | NA | NA |
| voter information about their district | 1 | 2.0 | 8.545177 | NA | NA |
| Alignment of floor vote breakdown with statewide majority of voters | 1 | 0.0 | 3.000000 | NA | NA |
| efficiency gap | 2 | 0.0 | 7.394449 | NA | NA |
| House-Senate Delegation alignment | 1 | 5.0 | 5.772589 | NA | NA |
| minority representation | 1 | 0.0 | 3.000000 | NA | NA |
| compactness | 1 | 0.0 | 7.394449 | NA | NA |
| equal population | 1 | 0.0 | 5.772589 | NA | NA |
| representation of majority opinion | 1 | 0.0 | 3.000000 | NA | NA |
| elite ideological moderation | 1 | 0.0 | 3.000000 | NA | NA |
| competitiveness | 2 | 2.0 | 7.394449 | NA | NA |
| legislative majority-seeking behavior | 1 | 0.0 | 3.000000 | NA | NA |
| community | 1 | 0.0 | 5.772589 | NA | NA |
| computers | 0 | 0.0 | 5.772589 | NA | NA |
| legislator information about district | 0 | 0.0 | 3.000000 | NA | NA |
| maintaining communities | 0 | 0.0 | 3.000000 | NA | NA |
| mean-median vote comparison | 0 | 0.0 | 5.772589 | NA | NA |
| majority minority districts | 0 | 0.0 | 8.545177 | NA | NA |
| redistricting commission | 0 | 0.0 | 8.545177 | NA | NA |
| social network | 0 | 0.0 | 3.000000 | NA | NA |
| change in constituency boundaries | 0 | 0.0 | 5.772589 | NA | NA |
| demographic and ideological sorting | 0 | 0.0 | 3.000000 | NA | NA |
| contiguity | 0 | 0.0 | 3.000000 | NA | NA |
| electorate composition change | 0 | 0.0 | 7.394449 | NA | NA |
| incumbent’s constituents change | 0 | 0.0 | 3.000000 | NA | NA |
| geographic clustering | 0 | 0.0 | 3.000000 | NA | NA |
| communities preserved | 0 | 0.0 | 7.394449 | NA | NA |
| redistricting by courts | 0 | 0.0 | 3.000000 | NA | NA |
| upcoming redistricting | 0 | 0.0 | 3.000000 | NA | NA |
par(mar=c(0,0,0,0)); plot(g)# what does %in% do?
1 %in% c(1,2,3,4)## [1] TRUE
1 %in% c(2,3,4)## [1] FALSE
#add a legend.
par(mar=c(0,0,0,0)); plot(g)
legend(x=.75, y=.75, legend=c("no type provided in node attributes sheet"),
pch=21, pt.bg=c("grey20"), pt.cex=2, bty="n")Edge properties can also be modified. Set the width of each edge as a function of the log number of studies two concepts appear together. Plot it.
E(g)$width <- log(E(g)$cite_weight) + 1
edge_attr(g) %>% as_tibble() %>% kablebox()| mechanism | cites | cites_empirical | cite_weight | edge_betweenness | width |
|---|---|---|---|---|---|
| Altman and McDonald (2010) argue that simulations cannot adequately detect gerrymanders. Wang proposes three tests to detect the effects and intents of gerrymanders. Altman and McDonald (2011) provide an open source program for redistricting analysis | Altman & McDonald 2010, Wang 2016, Altman & McDonald 2011 | Wang 2016 | 1 | 1.0 | 1.000000 |
| Altman & McDonald argue that computers can be used to allow the public to participate in the map-drawing process by soliciting information and education about redistricting. | Altman & McDonald 2010, Altman & McDonald 2011 | NA | 1 | 1.0 | 1.000000 |
| NA | Butler, D and Nickerson, D 2011; Broockman and Skovron 2018; and Hertel-Fernandez et al. 2018 | NA | 3 | 1.0 | 2.098612 |
| A partisan gerrymander aims to diverge from proportionality. | Caughey et al. 2017 | NA | 1 | 12.0 | 1.000000 |
| A partisan gerrymander aims to decrease the number of competitive district, but some research suggests that partisan gerrymanders have a neutral or positive effect on competition. | NA | NA | 5 | 1.5 | 2.609438 |
| Stephanopoulos argues that the Supreme Court ought to adopt a test of political gerrymandering based on the “territorial community.” In short, if a district map disrupts an organic geographic community, it is unconstitutional. | Stephanopoulos 2012 | NA | 1 | 1.0 | 1.000000 |
| McDonald & Best propose a new measure of detecting gerrymanders; compare a party’s median vote share in a district to its mean vote share. Wang proposes a similar measure of gerrymandering based on comparing mean and median vote shares. | McDonald & Best 2015, Wang 2016 | Wang 2016 | 1 | 1.0 | 1.000000 |
| McDonald & Best argue that their measure of gerryamndering can be extended to identify which gerrymanders are unconstitutional | McDonald & Best 2015 | NA | 1 | 1.0 | 1.000000 |
| Kang argues that it is unconstitutional for the government to take partisanship into account when determining district lines | Kang 2017 | NA | 1 | 2.0 | 1.000000 |
| Partisan mapmakers can create political instability, particularly for their opponent legislators, by breaking the link between representatives and constituents | Yoshinaka & Murhpy 2011 | Yoshinaka & Murhpy 2011 | 1 | 2.0 | 1.000000 |
| Masket et al. find that partisan redistricting do not have much effect on legislative polarization, as it is swamped by other factors | Masket et al. 2012 | Masket et al. 2012 | 1 | 2.0 | 1.000000 |
| Where minorities are a majority, they are have a better chance of electing a representative; Atsusaka 2021 creates a logical model that allows minority candidate appearance to be a result of (1) the electoral performance of coethnic candidates in the most recent elections and (2) the racial composition of a district. | Atsusaka 2021 | Atsusaka 2021 | 1 | 1.0 | 1.000000 |
| NA | NA | NA | 2 | 1.5 | 1.693147 |
| Cox and Holden argue that the optimal gerrymandering strategy is to cluster your strong partisan supporters into districts with a smaller number of strong partisan opponents. Thus, the Voting Rights Act’s majority-minority districts limit Republicans’ ability to effectively gerrymander. | Cox & Holden 2011 | NA | 1 | 8.5 | 1.000000 |
| African Americans are more likely to vote when reassigned to a majority black district. Fraga relies on a theoretical “empowerment framework,” in which members of minority groups are more likely to participate when their group has representation and influence in politics. | Fraga 2016 | Fraga 2016 | 1 | 1.0 | 1.000000 |
| Cain argues that independent citizen redistricting commissions are less likely to produce extremely partisan maps because they need to satisfy a supermajority by compromising on various redistricting criteria. | Cain 2011 | NA | 1 | 5.0 | 1.000000 |
| Stewart et al. introduce a concept called “information gerrymandering,” in which a small number of partisan extremists can sway the vote of the group towards their party. | Stewart et al. 2019 | NA | 1 | 1.0 | 1.000000 |
| Parties care about other resources in addition to votes, such as donations. They can use redistricting to concentrate likely donors into their districts and remove them from opponents’ districts, thus increasing their odds of reelection. | Kirkland 2013 | Kirkland 2013 | 1 | 2.0 | 1.000000 |
| Bertelli and Carson argue that partisan gerrymandering is a form of risk-sharing, in which individual members do not have to radically change their positions while maintaining their odds of reelection. In contrast, Hayes et al. say that legislators respond to the demographic changes of their constituency after redistricting. | Bertelli & Carson 2011, Hayes et al. 2010 | Bertelli & Carson 2011, Hayes et al. 2010 | 1 | 1.0 | 1.000000 |
| Bertelli & Carson: Partisan gerrymandering helps the majority party achieve its policy goals by increasing the odds of electoral success without requiring much sacrifice by individual members. Gul & Pesendorfer: use formal theory to show that policy outcomes are biased towards the redistricting party | Bertelli & Carson 2011, Gul & Pesendorfer 2010 | Bertelli & Carson 2011 | 1 | 1.0 | 1.000000 |
| Moskowitz & Schneer 2019: Residents of competitive districts systematically differ from those in non-competitive districts, leading cross-sectional studies to erroneously find a relationship between competitiveness and turnout. In addition, most voters aren’t aware of the competitiveness of their House race. Hunt 2018: examines data from Florida during 2012 election and finds that change in competitiveness after redistricting has a small effect on turnout | Moskowitz & Schneer 2019; Hunt 2018 | Moskowitz & Schneer 2019; Hunt 2018 | 2 | 3.0 | 1.693147 |
| Krasa & Polborn 2018: electoral competition model where gerrymandering (“intensification of the median ideological preferences in some districts”) can result in increased partisan polarization | Krasa & Polborn 2018 | Krasa & Polborn 2018 | 1 | 1.0 | 1.000000 |
| Democrats’ concentration in cities leads to a Republican bias, due to the geographic, majoritarian nature of U.S. elections. | Chen & Rodden 2013 | Chen & Rodden 2013 | 1 | 10.0 | 1.000000 |
| Redistricting destroys the connection between a representative and their constituents; the new constituents have no such bond, so incumbency advantage is lower. | Hood & McKee 2013 | Hood & McKee 2013 | 1 | 1.0 | 1.000000 |
| When a legislator’s district changes, the personal connection with some of their constituents is lost. Thus, legislators are less able to convert supporters of the opposite party, as they have no connections with their new constituents. | Carsey et al. 2017, Bertelli & Carson 2011 | Carsey et al. 2017 | 1 | 1.0 | 1.000000 |
| NA | Chen 2010 | NA | 1 | 6.0 | 1.000000 |
| NA | NA | NA | 1 | 2.0 | 1.000000 |
| NA | Hayes & McKee 2011 | Hayes & McKee 2011 | 1 | 2.0 | 1.000000 |
| NA | Winburn & Wagner 2010 | NA | 1 | 1.0 | 1.000000 |
| NA | Winburn & Wagner 2010 | NA | 1 | 2.0 | 1.000000 |
| NA | Winburn & Wagner 2010 | NA | 1 | 2.0 | 1.000000 |
| Candidates have their own campaign style, so their resource allocation decisions do not change even when the electoral circumstances change. | Limbocker & You 2020 | Limbocker & You 2020 | 1 | 1.0 | 1.000000 |
| Democrats are inefficiently geographically distributed; they run up the score in large cities which leads to a discrepency between total vote share and seat share. | Chen & Rodden 2013 | Chen & Rodden 2013 | 1 | 10.0 | 1.000000 |
| NA | Winburn & Wagner 2010 | NA | 1 | 2.0 | 1.000000 |
| NA | Winburn & Wagner 2010 | NA | 1 | 3.0 | 1.000000 |
| NA | Hayes & McKee 2011; Winburn & Wagner 2010 | Hayes & McKee 2011 | 2 | 1.0 | 1.693147 |
| Safe partisan seats tend to increase partisan polarization. | Grainger 2010 | Grainger 2010 | 1 | 2.5 | 1.000000 |
| TODO | Caughey et al. 2017 | NA | 1 | 4.0 | 1.000000 |
| TODO | Caughey et al. 2017 | NA | 1 | 4.0 | 1.000000 |
| Measures of partisan symmetry/bias/advantage | Katz, King & Rosenblatt 2020 | NA | 1 | 0.0 | 1.000000 |
| Legislators do not change their ideological positions after redistricting (though The Electoral Connection suggests they should) | Lo 2013 | Lo 2013 | 1 | 4.0 | 1.000000 |
| Because vulnerable legislators do not moderate their positions, Lo assumes that safe legislators do not become more extreme | Lo 2013 | NA | 1 | 3.5 | 1.000000 |
| Gerrymandering does not affect the electoral results in most states, and in the states where it does have an effect, the effect is small. Republicans are expected to net only one additional seat in Congress due to gerrymandering. | Chen & Cottrell 2016 | Chen & Cottrell 2016 | 1 | 4.0 | 1.000000 |
| Large changes in the national partisan tide causes garrymanders to backfire on the map-drawing party (an effect known as the “dummymander”), as their members face unexpectedly competitive elections. | Goedert 2017 | Goedert 2017, Yoshinaka & Murhpy 2011 | 1 | 1.5 | 1.000000 |
| NA | Chen 2010 | NA | 1 | 10.0 | 1.000000 |
| Webster 2013: citing earlier research, Webster posits that compactness hinders a map drawer’s ability to create districts for historically underrepresented groups. | Webster 2013 | NA | 1 | 1.0 | 1.000000 |
| Barnes & Solomon 2020: measuring compactness can have associated flexibility that can be abused (geography, topography, cartographic projections, and resolution); Gatesman & Unwin 2021: lattice models for accounting gerrymandered, equal-pop, connected districts; Magleby & Mosesson 2018: graph partition algorithm for drawing districts based on compactness and equal population metrics.De Assis et al. 2014: Greedy randomized adaptive search procedure can balance multiple criteria, including compactness. Altman & McDonald 2011: produce an open source package that allows users to adjust weights of redistricting criteria, including redistricting. Liu et al.; propose a method of parallel evolutionary computation to solve the optimization problem of redistricting. Chen & Rodden; simulation-based method also takes compactness into account to draw district maps and identify gerrymanders. Tam Cho & Liu; use compactness in their redistricting algorithm. Saxon 2020: software for applying compactness/contiguity/equipopulation objectives to evaluate maps – specific focus on different definitions of compactness. | Barnes & Solomon 2020; Gatesman & Unwin 2021; Magleby & Mosesson 2018; De Assis et al. 2014; Altman & McDonald 2011; Lie et al. 2016, Chen & Rodden 2015, Tam Cho & Liu 2016, Saxon 2020 | Barnes & Solomon 2020; Magleby & Mosesson 2018; De Assis et al. 2014; Chen & Rodden 2015, Tam Cho & Liu 2016, Saxon 2020 | 6 | 0.0 | 2.791759 |
| Stephanopoulos and McGhee propose a measure of partisan symmetry to be adopted by the courts, in order to limit partisan influence over redistricting; McGhee distinguishes efficiency from related concepts of symmetry and responsiveness | Stephanopoulos & McGhee 2015, McGhee 2014 | McGhee 2014 | 1 | 0.0 | 1.000000 |
| Gatesman & Unwin 2021: lattice models for accounting gerrymandered, equal-pop, connected districts; Magleby & Mosesson 2018: graph partition algorithm for drawing districts based on compactness and equal population metrics. Altman & McDonald 2011: produce an open source package that allows users to adjust weights of redistricting criteria, including equality of population | Gatesman & Unwin 2021; Magleby & Mosesson 2018 | Magleby & Mosesson 2018 | 2 | 0.0 | 1.693147 |
| Matsusaka does not discuss a mechanism for this relationship, but finds that other electoral rules, such as campaign finance regulations and ballot access rules, are also not associated with greater congruence between public opinion and legislative behavior. | Matsusaka 2010 | Matsusaka 2010 | 1 | 1.0 | 1.000000 |
| McGhee and Shor focus on the effect of the Top Two primary on elite moderation, but argue that the introduction of independent redistricting commissions may also lead to greater moderation by creating more competitive districts. | McGhee & Shor 2017 | McGhee & Shor 2017 | 1 | 1.0 | 1.000000 |
| Carson et al.: increased ideological polarization and the availability of redistricting computer software encourages elites to draw non-competitive districts in order to increase their odds of reelection. Masket et al.: partisan redistricting does not effect competition much and is swamped by other factors | Carson et al. 2014, Grainger 2010, Masket et al. 2012 | Carson et al. 2014, Grainger 2010, Masket et al. 2012 | 1 | 2.0 | 1.000000 |
| NA | Carson et al. 2014 | Carson et al. 2014 | 1 | 2.0 | 1.000000 |
| Parties have a greater incentive to become the majority party in the state legislature if redistricting is imminent and controlled by the legislature, as they can then determine the new district boundaries | Makse 2014 | Makse 2014 | 1 | 1.0 | 1.000000 |
| Deford, Eubank & Rodden 2020: new measure “partisan dislocation” which proxies for cracking/packing | Deford, Eubank & Rodden 2020 | NA | 1 | 0.0 | 1.000000 |
par(mar=c(0,0,0,0)); plot(g)Up to now, each time we run the plot function, the nodes appear to be in a different location. Why? Because it’s running a probabilistic function trying to locate them in the optimal way possible.
However, we can also specify the layout for the plot; that is, the (x,y) coordinates where each node will be placed. igraph has a few different layouts built-in, that will use different algorithms to find an optimal distribution of nodes. The following code illustrates some of these:
par(mfrow=c(2, 3), mar=c(0,0,1,0))
plot(g, layout=layout_randomly, main="Random")
plot(g, layout=layout_in_circle, main="Circle")
plot(g, layout=layout_as_star, main="Star")
plot(g, layout=layout_as_tree, main="Tree")
plot(g, layout=layout_on_grid, main="Grid")
plot(g, layout=layout_with_fr, main="Force-directed")Note that each of these is actually just a matrix of (x,y) locations for each node.
l <- layout_randomly(g)
str(l)## num [1:54, 1:2] -0.522 -0.184 -0.626 -0.108 -0.106 ...
The most popular layouts are force-directed. These algorithms, such as Fruchterman-Reingold, try to position the nodes so that the edges have similar length and there are as few crossing edges as possible. The idea is to generate “clean” layouts, where nodes that are closer to each other share more connections in common that those that are located further apart. Note that this is a non-deterministic algorithm: choosing a different seed will generate different layouts.
par(mfrow=c(1,2))
set.seed(777)
fr <- layout_with_fr(g, niter=1000)
par(mar=c(0,0,0,0)); plot(g, layout=fr)
set.seed(666)
fr <- layout_with_fr(g, niter=1000)
par(mar=c(0,0,0,0)); plot(g, layout=fr)Let’s look at descriptive statistics at the node level. All of these are in some way measures of importance or centrality.
The most basic measure is degree, the number of adjacent edges to each node. It is often considered a measure of direct influence. In the redistricting network, it will be the unique number of concepts that each concept is interacting with. Sort the degree of the network and print it out.
sort(-degree(g)) %>% head() %>% kable()| x | |
|---|---|
| partisan advantage | -13 |
| number of competitive districts | -5 |
| partisan gerrymandering | -5 |
| elite polarization | -4 |
| voter information about their district | -4 |
| majority minority districts | -4 |
Partisan advantage (degree=14), followed by a three way tie of communities preserved, partisan gerrymandering and compactness (each degree=5) are the most “central” concepts covered in the redistricting literature.
In directed graphs, there are three types of degree: indegree (incoming edges), outdegree (outgoing edges), and total degree. You can find these using mode="in" or mode="out" or mode="total".
Strength is a weighted measure of degree that takes into account the number of edges that go from one node to another. In this network, it will be the total number of interactions of each concept with any other concept. Sort the strength of the network and print it out.
sort(-strength(g)) %>% head() %>% kable()| x | |
|---|---|
| partisan advantage | -13 |
| number of competitive districts | -5 |
| partisan gerrymandering | -5 |
| elite polarization | -4 |
| voter information about their district | -4 |
| majority minority districts | -4 |
Closeness measures how many steps are required to access every other node from a given node. It’s a measure of how long information takes to arrive (who hears news first?). Higher values mean less centrality. Sort the closeness of the network (normalize it) and print it out.
sort(-closeness(g, normalized=TRUE))## majority minority districts
## -0.02369245
## contiguity
## -0.02261092
## geographic clustering
## -0.02261092
## partisan advantage
## -0.02219430
## redistricting commission
## -0.02217573
## communities preserved
## -0.02080879
## partisan gerrymandering
## -0.02000000
## voter information about their district
## -0.01960784
## electorate composition change
## -0.01960784
## computers
## -0.01923077
## mean-median vote comparison
## -0.01923077
## change in constituency boundaries
## -0.01923077
## proportionality
## -0.01922379
## incumbent's constituents change
## -0.01922379
## redistricting by courts
## -0.01922379
## number of competitive districts
## -0.01886792
## stability in voters' fellow constituents
## -0.01886792
## House-Senate Delegation alignment
## -0.01886792
## compactness
## -0.01886792
## competitiveness
## -0.01886792
## legislator information about district
## -0.01886792
## maintaining communities
## -0.01886792
## social network
## -0.01886792
## demographic and ideological sorting
## -0.01886792
## upcoming redistricting
## -0.01886792
## detect gerrymandering
## -0.01851852
## public participation
## -0.01851852
## floor votes align with district preferences
## -0.01851852
## constitutional test
## -0.01851852
## unconstitutional government interest
## -0.01851852
## instability
## -0.01851852
## elite polarization
## -0.01851852
## number of minority representatives
## -0.01851852
## voter turnout
## -0.01851852
## vote outcome
## -0.01851852
## concentration of likely donors in map-drawing party's districts
## -0.01851852
## legislator voting
## -0.01851852
## legislative outcomes
## -0.01851852
## incumbent vote share
## -0.01851852
## personal vote
## -0.01851852
## pork spending
## -0.01851852
## voter sense of place
## -0.01851852
## rolloff
## -0.01851852
## voter recall
## -0.01851852
## split ticket voting
## -0.01851852
## campaign resource allocation
## -0.01851852
## Alignment of floor vote breakdown with statewide majority of voters
## -0.01851852
## efficiency gap
## -0.01851852
## minority representation
## -0.01851852
## equal population
## -0.01851852
## representation of majority opinion
## -0.01851852
## elite ideological moderation
## -0.01851852
## legislative majority-seeking behavior
## -0.01851852
## community
## -0.01851852
Detect gerrymandering, public participation, floor votes align with district preferences, and constitutional tests are closest to all other concepts in the network.
Betweenness measures brokerage or gatekeeping potential. It is (approximately) the number of shortest paths between nodes that pass through a particular node. Sort the betweenness of the network and print it out.
sort(-betweenness(g)) %>% head() %>% kable()| x | |
|---|---|
| partisan advantage | -25.5 |
| proportionality | -8.0 |
| House-Senate Delegation alignment | -5.0 |
| partisan gerrymandering | -4.0 |
| voter information about their district | -2.0 |
| competitiveness | -2.0 |
Partisan advantage has by far the highest measure of brokerage/gatekeeping potential, followed by number of competitive districts. These two concepts allow for the fastest facilitation of ideas in the redistricting network; in other words, if we were to design a causal story and try to connect two concepts, the fastest way to connect them would most often be through the idea of partisan advantage.
Eigenvector centrality is a measure of being well-connected connected to the well-connected. First eigenvector of the graph adjacency matrix. Only works with undirected networks. Sort the returned vector from the eigen_centrality of the network and print it out. (not for this application)
sort(-eigen_centrality(g)$vector) %>% head() %>% kable()Page rank approximates probability that any message will arrive to a particular node. This algorithm was developed by Google founders, and originally applied to website links. Sort the returned vector from the page_rank of the network and print it out.
sort(page_rank(g)$vector)## computers
## 0.009933598
## legislator information about district
## 0.009933598
## maintaining communities
## 0.009933598
## mean-median vote comparison
## 0.009933598
## majority minority districts
## 0.009933598
## redistricting commission
## 0.009933598
## social network
## 0.009933598
## change in constituency boundaries
## 0.009933598
## demographic and ideological sorting
## 0.009933598
## contiguity
## 0.009933598
## electorate composition change
## 0.009933598
## incumbent's constituents change
## 0.009933598
## geographic clustering
## 0.009933598
## communities preserved
## 0.009933598
## redistricting by courts
## 0.009933598
## upcoming redistricting
## 0.009933598
## number of minority representatives
## 0.012044487
## partisan gerrymandering
## 0.012044487
## representation of majority opinion
## 0.012044487
## elite ideological moderation
## 0.012044487
## unconstitutional government interest
## 0.012493051
## instability
## 0.012493051
## concentration of likely donors in map-drawing party's districts
## 0.012493051
## incumbent vote share
## 0.012748117
## personal vote
## 0.012748117
## campaign resource allocation
## 0.012748117
## stability in voters' fellow constituents
## 0.012748117
## voter information about their district
## 0.012748117
## proportionality
## 0.012951004
## Alignment of floor vote breakdown with statewide majority of voters
## 0.012951004
## voter recall
## 0.013545564
## split ticket voting
## 0.013545564
## public participation
## 0.014155377
## legislative outcomes
## 0.014155377
## rolloff
## 0.016360084
## legislator voting
## 0.017172783
## minority representation
## 0.017275822
## compactness
## 0.017275822
## detect gerrymandering
## 0.018377156
## vote outcome
## 0.018377156
## legislative majority-seeking behavior
## 0.018377156
## competitiveness
## 0.020488045
## voter sense of place
## 0.020769497
## House-Senate Delegation alignment
## 0.020941951
## floor votes align with district preferences
## 0.021394562
## constitutional test
## 0.022598935
## number of competitive districts
## 0.026522858
## pork spending
## 0.027734256
## voter turnout
## 0.029459326
## partisan advantage
## 0.031949010
## elite polarization
## 0.046498445
## equal population
## 0.066223985
## community
## 0.066223985
## efficiency gap
## 0.086340028
Authority score is another measure of centrality initially applied to the Web. A node has high authority when it is linked by many other nodes that are linking many other nodes. Sort the returned vector from the authority_score of the network and print it out.
sort(authority_score(g)$vector)## detect gerrymandering
## 0.000000e+00
## public participation
## 0.000000e+00
## constitutional test
## 0.000000e+00
## partisan gerrymandering
## 0.000000e+00
## incumbent vote share
## 0.000000e+00
## personal vote
## 0.000000e+00
## rolloff
## 0.000000e+00
## voter recall
## 0.000000e+00
## split ticket voting
## 0.000000e+00
## campaign resource allocation
## 0.000000e+00
## stability in voters' fellow constituents
## 0.000000e+00
## voter information about their district
## 0.000000e+00
## minority representation
## 0.000000e+00
## compactness
## 0.000000e+00
## representation of majority opinion
## 0.000000e+00
## elite ideological moderation
## 0.000000e+00
## competitiveness
## 0.000000e+00
## computers
## 0.000000e+00
## legislator information about district
## 0.000000e+00
## maintaining communities
## 0.000000e+00
## mean-median vote comparison
## 0.000000e+00
## majority minority districts
## 0.000000e+00
## redistricting commission
## 0.000000e+00
## social network
## 0.000000e+00
## change in constituency boundaries
## 0.000000e+00
## demographic and ideological sorting
## 0.000000e+00
## contiguity
## 0.000000e+00
## electorate composition change
## 0.000000e+00
## incumbent's constituents change
## 0.000000e+00
## geographic clustering
## 0.000000e+00
## communities preserved
## 0.000000e+00
## redistricting by courts
## 0.000000e+00
## upcoming redistricting
## 0.000000e+00
## vote outcome
## 8.072852e-19
## pork spending
## 8.072852e-19
## voter sense of place
## 8.072852e-19
## equal population
## 8.072852e-19
## legislative majority-seeking behavior
## 8.072852e-19
## community
## 8.072852e-19
## House-Senate Delegation alignment
## 1.614570e-18
## legislative outcomes
## 3.444696e-02
## unconstitutional government interest
## 5.018016e-02
## instability
## 5.018016e-02
## concentration of likely donors in map-drawing party's districts
## 5.018016e-02
## number of minority representatives
## 1.449684e-01
## voter turnout
## 1.567342e-01
## proportionality
## 3.899817e-01
## Alignment of floor vote breakdown with statewide majority of voters
## 3.899817e-01
## floor votes align with district preferences
## 4.216329e-01
## efficiency gap
## 4.216329e-01
## legislator voting
## 4.244286e-01
## elite polarization
## 5.179206e-01
## partisan advantage
## 6.294541e-01
## number of competitive districts
## 1.000000e+00
Finally, not exactly a measure of centrality, but we can learn more about who each node is connected to by using the following functions: neighbors (for direct neighbors) and ego (for neighbors up to n neighbors away). Find the neighbors of “partisan advantage”. Find the concept’s neighbors up to order 2 away.
neighbors(g, v=which(V(g)$name=="partisan advantage"))## + 9/54 vertices, named, from 3476abf:
## [1] floor votes align with district preferences
## [2] proportionality
## [3] number of competitive districts
## [4] number of competitive districts
## [5] elite polarization
## [6] partisan advantage
## [7] legislator voting
## [8] Alignment of floor vote breakdown with statewide majority of voters
## [9] efficiency gap
ego(g, order=2, nodes=which(V(g)$name=="partisan advantage"))## [[1]]
## + 19/54 vertices, named, from 3476abf:
## [1] partisan advantage
## [2] floor votes align with district preferences
## [3] proportionality
## [4] number of competitive districts
## [5] elite polarization
## [6] legislator voting
## [7] Alignment of floor vote breakdown with statewide majority of voters
## [8] efficiency gap
## [9] majority minority districts
## [10] contiguity
## + ... omitted several vertices
Let’s now try to describe what a network looks like as a whole. We can start with measures of the size of a network. diameter is the length of the longest path (in number of edges) between two nodes. We can use get_diameter to identify this path. mean_distance is the average number of edges between any two nodes in the network. We can find each of these paths between pairs of edges with distances. Find the diameter and mean distances of the network.
diameter(g, directed=TRUE, weights=NA)## [1] 4
get_diameter(g, directed=TRUE, weights=NA)## + 5/54 vertices, named, from 3476abf:
## [1] majority minority districts partisan advantage
## [3] proportionality House-Senate Delegation alignment
## [5] pork spending
mean_distance(g, directed=TRUE)## [1] 1.556818
dist <- distances(g, weights=NA)
dist[1:5, 1:5]## detect gerrymandering
## detect gerrymandering 0
## public participation 2
## floor votes align with district preferences Inf
## proportionality Inf
## number of competitive districts Inf
## public participation
## detect gerrymandering 2
## public participation 0
## floor votes align with district preferences Inf
## proportionality Inf
## number of competitive districts Inf
## floor votes align with district preferences
## detect gerrymandering Inf
## public participation Inf
## floor votes align with district preferences 0
## proportionality 2
## number of competitive districts 2
## proportionality
## detect gerrymandering Inf
## public participation Inf
## floor votes align with district preferences 2
## proportionality 0
## number of competitive districts 2
## number of competitive districts
## detect gerrymandering Inf
## public participation Inf
## floor votes align with district preferences 2
## proportionality 2
## number of competitive districts 0
edge_density is the proportion of edges in the network over all possible edges that could exist. Find the edge_density of the network.
edge_density(g)## [1] 0.01921733
# 22*21 possible edges / 2 because it's undirected = 231 possible edges
# but only 60 exist
60/((22*21)/2)## [1] 0.2597403
reciprocity measures the propensity of each edge to be a mutual edge; that is, the probability that if i is connected to j, j is also connected to i. Find the reciprocity of the network – you should find that it is 1. Explain why you think reciprocity=1 in this case.
reciprocity(g)## [1] 0
transitivity, also known as clustering coefficient, measures that probability that adjacent nodes of a network are connected. In other words, if i is connected to j, and j is connected to k, what is the probability that i is also connected to k? Find the transitivity of the network.
transitivity(g)## [1] 0.08490566
Networks often have different clusters or communities of nodes that are more densely connected to each other than to the rest of the network. Let’s cover some of the different existing methods to identify these communities.
The most straightforward way to partition a network is into connected components. Each component is a group of nodes that are connected to each other, but not to the rest of the nodes. For example, this network has two components.
# components(g)
par(mar=c(0,0,0,0)); plot(g)Most networks have a single giant connected component that includes most nodes. Most studies of networks actually focus on the giant component (e.g. the shortest path between nodes in a network with two or more component is Inf!).
giant <- decompose(g)[[1]]Components can be weakly connected (in undirected networks) or __strongly connected (in directed networks, where there is an edge that ends in every single node of that component).
Even within a giant component, there can be different subsets of the network that are more connected to each other than to the rest of the network. The goal of community detection algorithms is to identify these subsets.
There are a few different algorithms, each following a different logic.
The walktrap algorithm finds communities through a series of short random walks. The idea is that these random walks tend to stay within the same community. The length of these random walks is 4 edges by default, but you may want to experiment with different values. The goal of this algorithm is to identify the partition that maximizes a modularity score.
cluster_walktrap(giant)## IGRAPH clustering walktrap, groups: 3, mod: 0.26
## + groups:
## $`1`
## [1] "detect gerrymandering" "mean-median vote comparison"
##
## $`2`
## [1] "public participation" "computers"
##
## $`3`
## [1] "constitutional test" "maintaining communities"
##
cluster_walktrap(giant, steps=10)## IGRAPH clustering walktrap, groups: 3, mod: 0.26
## + groups:
## $`1`
## [1] "detect gerrymandering" "mean-median vote comparison"
##
## $`2`
## [1] "public participation" "computers"
##
## $`3`
## [1] "constitutional test" "maintaining communities"
##
Other methods are:
cluster_edge_betweenness(giant)## IGRAPH clustering edge betweenness, groups: 2, mod: 0.22
## + groups:
## $`1`
## [1] "detect gerrymandering" "constitutional test"
## [3] "maintaining communities" "mean-median vote comparison"
##
## $`2`
## [1] "public participation" "computers"
##
cluster_infomap(giant)## IGRAPH clustering infomap, groups: 1, mod: 0
## + groups:
## $`1`
## [1] "detect gerrymandering" "public participation"
## [3] "constitutional test" "computers"
## [5] "maintaining communities" "mean-median vote comparison"
##
cluster_label_prop(giant)## IGRAPH clustering label propagation, groups: 3, mod: 0.18
## + groups:
## $`1`
## [1] "detect gerrymandering" "public participation" "computers"
##
## $`2`
## [1] "constitutional test" "mean-median vote comparison"
##
## $`3`
## [1] "maintaining communities"
##
Infomap tends to work better in most social science examples (websites, social media, classrooms, etc), but fastgreedy is faster.
igraph also makes it very easy to plot the resulting communities:
# undirected graphs only
comm <- cluster_infomap(giant)
modularity(comm) # modularity score
par(mar=c(0,0,0,0)); plot(comm, giant)Alternatively, we can also add the membership to different communities as a color parameter in the igraph object.
# for undirected graphs
V(giant)$color <- membership(comm)
par(mar=c(0,0,0,0)); plot(giant)The final way in which we can think about network communities is in terms of hierarchy or structure. We’ll discuss one of these methods.
K-core decomposition allows us to identify the core and the periphery of the network. A k-core is a maximal subnet of a network such that all nodes have at least degree K.
coreness(g)## detect gerrymandering
## 1
## public participation
## 1
## floor votes align with district preferences
## 1
## proportionality
## 1
## number of competitive districts
## 2
## constitutional test
## 1
## unconstitutional government interest
## 1
## instability
## 1
## elite polarization
## 2
## number of minority representatives
## 1
## partisan advantage
## 3
## voter turnout
## 2
## partisan gerrymandering
## 2
## vote outcome
## 1
## concentration of likely donors in map-drawing party's districts
## 1
## legislator voting
## 1
## legislative outcomes
## 1
## incumbent vote share
## 1
## personal vote
## 1
## pork spending
## 1
## voter sense of place
## 1
## rolloff
## 2
## voter recall
## 1
## split ticket voting
## 1
## campaign resource allocation
## 1
## stability in voters' fellow constituents
## 1
## voter information about their district
## 2
## Alignment of floor vote breakdown with statewide majority of voters
## 1
## efficiency gap
## 3
## House-Senate Delegation alignment
## 1
## minority representation
## 1
## compactness
## 2
## equal population
## 2
## representation of majority opinion
## 1
## elite ideological moderation
## 1
## competitiveness
## 2
## legislative majority-seeking behavior
## 1
## community
## 2
## computers
## 1
## legislator information about district
## 1
## maintaining communities
## 1
## mean-median vote comparison
## 1
## majority minority districts
## 2
## redistricting commission
## 2
## social network
## 1
## change in constituency boundaries
## 1
## demographic and ideological sorting
## 1
## contiguity
## 1
## electorate composition change
## 1
## incumbent's constituents change
## 1
## geographic clustering
## 1
## communities preserved
## 2
## redistricting by courts
## 1
## upcoming redistricting
## 1
which(coreness(g)==6) # what is the core of the network?## named integer(0)
which(coreness(g)==1) # what is the periphery of the network?## detect gerrymandering
## 1
## public participation
## 2
## floor votes align with district preferences
## 3
## proportionality
## 4
## constitutional test
## 6
## unconstitutional government interest
## 7
## instability
## 8
## number of minority representatives
## 10
## vote outcome
## 14
## concentration of likely donors in map-drawing party's districts
## 15
## legislator voting
## 16
## legislative outcomes
## 17
## incumbent vote share
## 18
## personal vote
## 19
## pork spending
## 20
## voter sense of place
## 21
## voter recall
## 23
## split ticket voting
## 24
## campaign resource allocation
## 25
## stability in voters' fellow constituents
## 26
## Alignment of floor vote breakdown with statewide majority of voters
## 28
## House-Senate Delegation alignment
## 30
## minority representation
## 31
## representation of majority opinion
## 34
## elite ideological moderation
## 35
## legislative majority-seeking behavior
## 37
## computers
## 39
## legislator information about district
## 40
## maintaining communities
## 41
## mean-median vote comparison
## 42
## social network
## 45
## change in constituency boundaries
## 46
## demographic and ideological sorting
## 47
## contiguity
## 48
## electorate composition change
## 49
## incumbent's constituents change
## 50
## geographic clustering
## 51
## redistricting by courts
## 53
## upcoming redistricting
## 54
# Visualizing network structure
V(g)$coreness <- coreness(g)
par(mfrow=c(2, 3), mar=c(0.1,0.1,1,0.1))
set.seed(777); fr <- layout_with_fr(g)
for (k in 1:6){
V(g)$color <- ifelse(V(g)$coreness>=k, "orange", "grey")
plot(g, main=paste0(k, '-core shell'), layout=fr)
}wc <- cluster_walktrap(g)
modularity(wc)## [1] 0.6752067
membership(wc)## detect gerrymandering
## 1
## public participation
## 1
## floor votes align with district preferences
## 4
## proportionality
## 6
## number of competitive districts
## 4
## constitutional test
## 1
## unconstitutional government interest
## 2
## instability
## 2
## elite polarization
## 4
## number of minority representatives
## 4
## partisan advantage
## 4
## voter turnout
## 2
## partisan gerrymandering
## 2
## vote outcome
## 10
## concentration of likely donors in map-drawing party's districts
## 2
## legislator voting
## 5
## legislative outcomes
## 5
## incumbent vote share
## 7
## personal vote
## 7
## pork spending
## 6
## voter sense of place
## 3
## rolloff
## 3
## voter recall
## 3
## split ticket voting
## 3
## campaign resource allocation
## 7
## stability in voters' fellow constituents
## 3
## voter information about their district
## 3
## Alignment of floor vote breakdown with statewide majority of voters
## 4
## efficiency gap
## 4
## House-Senate Delegation alignment
## 6
## minority representation
## 8
## compactness
## 8
## equal population
## 11
## representation of majority opinion
## 2
## elite ideological moderation
## 2
## competitiveness
## 2
## legislative majority-seeking behavior
## 9
## community
## 12
## computers
## 1
## legislator information about district
## 4
## maintaining communities
## 1
## mean-median vote comparison
## 1
## majority minority districts
## 4
## redistricting commission
## 2
## social network
## 10
## change in constituency boundaries
## 5
## demographic and ideological sorting
## 4
## contiguity
## 4
## electorate composition change
## 7
## incumbent's constituents change
## 4
## geographic clustering
## 4
## communities preserved
## 3
## redistricting by courts
## 2
## upcoming redistricting
## 9
V(g)$shortname<-V(g)$name #shortened easier to read ver name
V(g)$shortname[V(g)$shortname=="concentration of likely donors in map-drawing party's districts"]<- "donor concentration"
V(g)$shortname[V(g)$shortname=="individual legislator voting"]<- "legislator voting"
V(g)$shortname[V(g)$shortname=="effect of personal vote"]<- "personal vote"
V(g)$shortname[V(g)$shortname=="detect gerrymandering"]<- "detect gerrymander"
V(g)$shortname[V(g)$shortname=="proportional minority representation"]<- "prop. minority rep"
V(g)$shortname[V(g)$shortname=="Number of competitive districts"]<- "no. competitive district"
V(g)$shortname[V(g)$shortname=="legislator information about district"]<- "legis. info on district"
V(g)$shortname[V(g)$shortname=="floor votes align with district preferences"]<- "legis. votes with district pref."
V(g)$shortname[V(g)$shortname=="stability in voters' fellow constituents"]<- "constituent stability"
V(g)$shortname[V(g)$shortname=="voter information about their district"]<- "voter info on district"
V(g)$shortname[V(g)$shortname=="legislator information seeking"]<- "legis. info-seek"
V(g)$shortname[V(g)$shortname=="Alignment of floor vote breakdown with statewide majority of voters"]<- "Floor vote align state voters"
V(g)$shortname[V(g)$shortname=="number of competitive districts" ]<- "no. competitive district"
V(g)$shortname[V(g)$shortname=="House-Senate Delegation alignment" ]<- "Congress-SH align"
V(g)$shortname[V(g)$shortname=="unconstitutional government interest"]<- "unconstit gov interest"
V(g)$shortname[V(g)$shortname=="number of minority representatives"]<- "no. minority reps"
V(g)$shortname[V(g)$shortname=="representation of majority opinion"]<- "represent majority opinion"
V(g)$shortname[V(g)$shortname=="elite ideological moderation"]<- "elite ideol moderation"
V(g)$shortname[V(g)$shortname=="partisan gerrymandering"]<- "partisan gerrymander"
V(g)$shortname[V(g)$shortname=="legislative majority-seeking behavior"]<- "legis majority-seeking behavior"
V(g)$shortname[V(g)$shortname=="change in constituency boundaries"]<- "change constituent boundary"
V(g)$shortname[V(g)$shortname=="demographic and ideological sorting"]<- "demog/ideol sorting"
V(g)$shortname[V(g)$shortname=="dispersed minority population"]<- "dispersed minority pop"
V(g)$shortname[V(g)$shortname=="majority minority districts"]<- "majority minority district"
set.seed(123)
pdf(file=here::here("figs","redistrict_communities.pdf"),width=13,height=13)
plot(g)
plot(wc, g, vertex.label=V(g)$shortname,vertex.label.dist=1,vertex.color="gray20")
dev.off()## quartz_off_screen
## 2
plot(g)